package com.example.system.util;


import lombok.Data;


@Data
public class ServerResponse<T> {

    private Integer status;
    private T data;
    private String msg;

    public static <T> ServerResponse createSuccess(T data) {
        return new ServerResponse(0, data);
    }

    public static ServerResponse createSuccess() {
        return new ServerResponse(0);
    }

    public static ServerResponse createError() {
        return new ServerResponse(1);
    }

    public static ServerResponse createError(String msg) {
        return new ServerResponse(1, msg);
    }

    public static ServerResponse createError(Integer status,String msg) {
        return new ServerResponse(status, msg);
    }

    public static ServerResponse createSuccess(String msg) {
        return new ServerResponse(0, msg);
    }

    public ServerResponse(Integer status, T data) {
        this.status = status;
        this.data = data;
    }

    public ServerResponse(Integer status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public ServerResponse(Integer status) {
        this.status = status;
    }

    public ServerResponse() {
    }

}
